// Mapping & Modifiers (readonly，-，?)

// 循环添加readonly，
type CustomReadonly<T> = {
  readonly [Key in keyof T]: T[Key];
};

type X = {
  a: string;
  b: string;
  [key: number]: any;
};

type RemoveReadonly<T> = {
  -readonly [Key in keyof T]: T[Key];
};

type Test = RemoveReadonly<X>;

[].map((el) => "");

const z: X = {
  a: "1",
  b: "2",
  0: "a",
};

// Challenge Recreate the Utility Types
// 挑战重新创建实用程序类型

// 1.MyPartial，
type MyPartial<T> = {
  // 生成的属性可以不存在或者为undefined
  [P in keyof T]?: T[P];
};

type Result = MyPartial<X>;

// 2.Transform,将每个值类型转化为指定类型
type Transform<T, U> = {
  [P in keyof T]: U;
};

type Result2 = Transform<X, boolean>;

// 3.MyPick
type MyPick<T, K extends keyof T> = {
  [P in K]: T[P];
};
type Result3 = MyPick<X, "a">;

export {};
